﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Xinnos.Lca.Yacht.Analyzer.View
{
    /// <summary>
    /// WorkBreakdownStructurePanel.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class WorkBreakdownStructurePanel : UserControl
    {
        public event EventHandler Confirmed;
        private WorkBreakdownStructureViewModel mViewModel = null;
        public WorkBreakdownStructurePanel()
        {
            InitializeComponent();

            if (null == mViewModel)
            {
                mViewModel = new WorkBreakdownStructureViewModel();
                this.DataContext = mViewModel;
            }
        }

        private void OnCanExecuteConfirmCommand(object sender, CanExecuteRoutedEventArgs e)
        {
            WorkBreakdownStructureViewModel _context = this.DataContext as WorkBreakdownStructureViewModel;
            e.CanExecute = null == _context ? false : !(string.IsNullOrEmpty(_context.Code) || string.IsNullOrEmpty(_context.Name));
        }
        private void OnExecuteConfirmCommand(object sender, ExecutedRoutedEventArgs e)
        {
            if (null != this.Confirmed) this.Confirmed(this, null);
        }
    }
}
